package com.lianziyou.coin.price.controller;

import static com.lianziyou.coin.price.service.IGetPriceService.COIN_PRICE_REDIS_HASH_KEY;

import com.lianziyou.coin.price.vo.PriceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.cloud.annotation.SystemResource;
import org.cloud.core.redis.RedisUtil;
import org.cloud.vo.CommonApiResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(value = "币价相关API", tags = "币价相关API")
@SystemResource(path = "/system/coin/price", description = "币价相关API")
public class CoinPriceController {

    @GetMapping
    @ApiOperation("获取价格")
    public CommonApiResult<PriceVO> getPrice(String pairName) {
        PriceVO priceVO = RedisUtil.single().hashGet(COIN_PRICE_REDIS_HASH_KEY, pairName);
        return CommonApiResult.createSuccessResult(priceVO);
    }
}
